﻿<%@ Page Title="" Language="C#" MasterPageFile="~/UI/Main/Main.Master" AutoEventWireup="true"
    CodeBehind="Contacts.aspx.cs" Inherits="OrganizedIN.UI.GroupContact.SearchUser" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .Header
        {
            background: #6D84B4;
            border: 1px solid #3B5998;
            color: white;
            font-size: 14px;
            font-weight: bold;
            margin: 0px;
            display: block;
            height: 25px;
            width: 99%;
        }
        .Header a, a:hover
        {
            color: white;
            font-size: 14px;
            font-weight: bold;
            text-decoration: underline;
            cursor: pointer;
        }
        .Header a:hover
        {
            color: white;
            font-size: 14px;
            font-weight: bold;
            text-decoration: underline;
            cursor: pointer;
        }
        .Content
        {
            border: 1px solid #3B5998;
            width: 99%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Accordion ID="Accordion1" runat="server" SelectedIndex="0" FadeTransitions="true"
        FramesPerSecond="40" TransitionDuration="250" AutoSize="None" ContentCssClass="Content"
        HeaderCssClass="Header">
        <Panes>
            <asp:AccordionPane runat="server" ID="apRequests">
                <Header>
                    <a href="" onclick="return false;">Contact Requests</a>
                </Header>
                <Content>
                    <br />
                    <asp:GridView ID="gvRequests" runat="server" EmptyDataText="No New Contact Requests"
                        AllowPaging="True" AutoGenerateColumns="False" BorderColor="White" HeaderStyle-ForeColor="Purple"
                        PageSize="20" Width="80%" OnRowCommand="gvRequests_RowCommand" DataSourceID="dsContactRequest">
                        <HeaderStyle ForeColor="Purple" />
                        <RowStyle BorderColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderStyle-BackColor="#c2cee7" HeaderStyle-Font-Bold="true" HeaderText="Contact Information">
                                <ItemTemplate>
                                    <table width="100%">
                                        <tr>
                                            <td rowspan="3" width="10%">
                                                <asp:ImageButton ID="imgUser" runat="server" Height="70px" ImageUrl='<%# Eval("ProfilePicture") %>'
                                                    Width="100%" CommandArgument='<%# Eval("username") %>' CommandName="view" />
                                            </td>
                                            <td>
                                                <asp:Label ID="lblUname" runat="server" Text='<%# Eval("Name") %>' Font-Bold="True"
                                                    Font-Size="13px" ForeColor="#6D84B4"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:Label ID="lblGender" Text='<%# Eval("Gender") %>' runat="server"></asp:Label>
                                                ,
                                                <asp:Label ID="lblDOB" Text='<%# Eval("DOB") %>' runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:Label ID="lblEmail" runat="server" Text='<%# Eval("username") %>'></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                                <HeaderStyle BackColor="#C2CEE7" Font-Bold="True"></HeaderStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderStyle-BackColor="#c2cee7" HeaderStyle-Font-Bold="true" HeaderStyle-Width="10%"
                                ItemStyle-VerticalAlign="Middle">
                                <ItemTemplate>
                                    <asp:ImageButton ID="btnConfirm" runat="server" CommandArgument='<%# Eval("ContactID") %>'
                                        CommandName="confirm" ImageUrl="~/images/accept.png" ToolTip="Confirm Request" />
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    <asp:ImageButton ID="btnDelete" CommandName="reject" CommandArgument='<%# Eval("ContactID") %>'
                                        runat="server" ImageUrl="~/images/delete.png" ToolTip="Reject Request" />
                                </ItemTemplate>
                                <HeaderStyle BackColor="#C2CEE7" Font-Bold="True" />
                                <ItemStyle VerticalAlign="Top"></ItemStyle>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <br />
                    <asp:SqlDataSource ID="dsContactRequest" runat="server" ConnectionString="<%$ ConnectionStrings:OrganizedInConnectionString %>"
                        SelectCommand="SELECT     COALESCE (UserInformation.FirstName, '') + ' ' + COALESCE (UserInformation.LastName, '') AS Name, 
                      CASE WHEN (UserInformation.ProfilePicture = '' OR
                      UserInformation.ProfilePicture IS NULL) THEN '~/images/user-icon.jpg' ELSE UserInformation.ProfilePicture END AS ProfilePicture, 
                      UserInformation.DOB, UserInformation.Gender, Contact.Contact_ID as ContactID, Contact.FrndshpDate, UserInformation.username
FROM         Contact INNER JOIN
                      UserInformation ON Contact.ToUName = UserInformation.username
WHERE     (Contact.Approved = 0) AND (Contact.Rejected = 0) AND (Contact.FromUName = @Uname)">
                        <SelectParameters>
                            <asp:SessionParameter Name="Uname" SessionField="UserID" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </Content>
            </asp:AccordionPane>
            <asp:AccordionPane runat="server" ID="apExisting">
                <Header>
                    <a href="" onclick="return false;">Existing Contacts</a>
                </Header>
                <Content>
                    <asp:Repeater ID="rptrExistingUsers" runat="server">
                        <HeaderTemplate>
                            <ul class="holder1">
                        </HeaderTemplate>
                        <ItemTemplate>
                            <li class="bit-box1">
                                <center>
                                    <asp:Image ID="Image1" runat="server" Style="display: inline" ImageUrl='<%# Eval("ProfilePicture") %>'
                                        Height="60px" Width="50px" /><br />
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name") %>' Font-Bold="True"
                                        Font-Size="13px" ForeColor="#6D84B4"></asp:Label>
                                    <a title="Remove Contact From Group" href='<%# String.Format("?action=Remove&uid={0}",Eval("username")) %>'
                                        class="closebutton"></a>
                                </center>
                            </li>
                        </ItemTemplate>
                        <FooterTemplate>
                            </ul>
                        </FooterTemplate>
                    </asp:Repeater>
                </Content>
            </asp:AccordionPane>
            <asp:AccordionPane runat="server" ID="apSearch">
                <Header>
                    <a href="" onclick="return false;">Search Contacts</a>
                </Header>
                <Content>
                    <table width="100%">
                        <tr>
                            <td width="20%">
                                <b>Enter Search Phrase</b>
                            </td>
                            <td>
                                <asp:TextBox ID="txtSearch" runat="server" Width="373px"></asp:TextBox><asp:RequiredFieldValidator
                                    ID="rfvSearch" runat="server" ErrorMessage="*" Display="Dynamic" ValidationGroup="search"
                                    ControlToValidate="txtSearch"></asp:RequiredFieldValidator>
                                &nbsp;&nbsp;&nbsp;
                                <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
                                    ValidationGroup="search" />&nbsp;<asp:Label ID="lblError" runat="server" ForeColor="Red"
                                        Text=""></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Repeater ID="rptrUsers" runat="server">
                                    <HeaderTemplate>
                                        <table width="95%" cellpadding="0" style="border: 1px solid #3B5998;" cellspacing="0">
                                            <tr>
                                                <td colspan="2" style="background-color: #6D84B4; color: #FFFFFF; font-weight: bold;
                                                    font-family: arial, Helvetica, sans-serif; font-size: medium;">
                                                    User Search Result
                                                </td>
                                            </tr>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <tr>
                                            <td width="85%">
                                                <table width="100%">
                                                    <tr>
                                                        <td rowspan="3" width="10%">
                                                            <asp:ImageButton ID="imgUser" runat="server" Height="70px" ImageUrl='<%# Eval("ProfilePicture") %>'
                                                                Width="100%" CommandArgument='<%# Eval("username") %>' CommandName="view" OnClick="btnAdd_Click" />
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="lblUname" runat="server" Text='<%# Eval("Name") %>' Font-Bold="True"
                                                                Font-Size="13px" ForeColor="#6D84B4"></asp:Label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <asp:Label ID="lblGender" Text='<%# Eval("Gender") %>' runat="server"></asp:Label>
                                                            ,
                                                            <asp:Label ID="lblDOB" Text='<%# Eval("DOB") %>' runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <asp:Label ID="lblEmail" runat="server" Text='<%# Eval("username") %>'></asp:Label>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                            <td align="right" style="border-left-style: solid; border-left-width: 1px; border-left-color: #000000">
                                                <asp:ImageButton ID="btnAdd" runat="server" Visible='<%# !Convert.ToBoolean(Eval("IsFriend").ToString())  %>'
                                                    CommandArgument='<%# Eval("username") %>' CommandName="select" ImageUrl="~/images/add_friend.jpg"
                                                    OnClick="btnAdd_Click" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" style="height: 1px; background-color: Black">
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </table>
                                    </FooterTemplate>
                                </asp:Repeater>
                            </td>
                        </tr>
                    </table>
                </Content>
            </asp:AccordionPane>
        </Panes>
    </asp:Accordion>
</asp:Content>
